﻿//////////////////////////////////////////////////////////////////
//
// Helen\Cell.cs
//
// Copyright (c) 2012 Dan Pike.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Helen
{
   /// <summary>
   /// This structure is used to calculate the data that we will write to the
   /// output file
   /// </summary>
   public struct Cell
   {
      /// <summary>
      /// Height of this vertex
      /// </summary>
      public short Height;

      /// <summary>
      /// Face normals of the two triangles for which this vertex is the SW-corner
      /// of a square "cell". faceNormal0 is the normal of the bottom-left triangle
      /// and faceNormal1 is the normal of the top-right triangle:
      /// 
      ///           +-----+
      ///           |\    |
      ///           | \ 1 |
      ///           |  \  |
      ///           | 0 \ |
      ///           |    \|
      ///  Vertex-> +-----+
      ///   
      /// </summary>
      public Vector3 faceNormal0;
      public Vector3 faceNormal1;

      /// <summary>
      /// The normalized average normal of all of the faces that surround this vertex.
      /// Is not defined for vertices that are on the edge of the square (they are
      /// intermediate values taken from the adjacent cells so that we can calculate
      /// the face normals properly; they are not written to the output file)
      /// </summary>
      public Vector3 vertexNormal;
   }
}
